package sg.edu.nus.iss.umpire.service.umpire;

import sg.edu.nus.iss.umpire.dao.UmpireDao;
import sg.edu.nus.iss.umpire.dao.jpa.UmpireDAOImpl;
import sg.edu.nus.iss.umpire.support.HttpMethod;
import sg.edu.nus.iss.umpire.support.Service;
import sg.edu.nus.iss.umpire.support.ServiceConfig;
import sg.edu.nus.iss.umpire.support.ServiceContext;

@ServiceConfig(path = "umpires/delete", method = HttpMethod.POST)
public class DeleteUmpireService implements Service {
	@Override
	public String serve(ServiceContext ctx) throws Exception {
		String[] keys = ctx.getRequest().getParameter("keys").split(",");
		UmpireDao dao = new UmpireDAOImpl(ctx.getEntityManager());
		for (String keyStr : keys) {
			dao.deleteByKey(Long.valueOf(keyStr));
		}
		return null;
	}
}
